package pattern.behavior.state;

import pattern.behavior.state.impl.Completed;
import pattern.behavior.state.impl.Paid;
import pattern.behavior.state.impl.PendingPayment;

public class Order {

    private OrderState state;

    public Order() {
        state = new PendingPayment();
    }

    public void setState(OrderState orderState) {
        this.state = orderState;
    }

    public void pay() {
        state.pay();
    }

    public void cancel() {
        state.cancel();
    }

    public void complete() {
        state.complete();
    }

    public static void main(String[] args) {
        Order order = new Order();
        order.pay();

        order.setState(new Paid());
        order.cancel();

        order.setState(new Completed());
        order.complete();
    }
}
